<ul class="submenu">
	<li><?php echo anchor($this->curl . '/create', T_('New Category'), 'class="arrow-right"')?></li>
	<li><a href="javascript:void(0)" onclick="if (confirm('<?php echo T_('Are you sure you want to delete these data?'); ?>')) deleteItems('/admin/<?php echo $this->curl; ?>/deleteItems/');return false;"><?php echo T_('Delete Selected'); ?></a></li>
</ul>

<?php echo form_open('/' . $this->curl . '/index/', 'id="myform" name="myform"')?>

<table width="100%" border="0" cellpadding="3" cellspacing="0" id="grid" class="display">
<thead>
<tr>
  <th class="first"><?php echo form_checkbox('cid_toggle', null, FALSE, 'id="cid_toggle" onclick="toggleCheckboxes($(this))"')?></th>
  <th><?php echo $this->category_model->fields['name'] ?></th>
  <th><?php echo $this->category_model->fields['description'] ?></th>
  <th>&nbsp;</th>
</tr>
</thead>
<tbody>
<?php foreach ($list as $row): ?>
<tr id="tr_<?php echo $row->id?>">
  <td class="t-center"><?php echo form_checkbox('cid[]', $row->id, FALSE, 'class="checkbox" id="cb'. $row->id.'"')?></td>
  <td><?php echo $row->name; ?></td>
  <td><?php echo $row->description; ?></td>
  <td width="26" class="t-center"><?php echo anchor($this->curl.'/edit/'.$row->id, ' ', 'class="btn_edit" alt="'.T_('Edit').'" title="'.T_('Edit').'"')?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
  
<?php echo form_close()?>

<script type="text/javascript">
var oTable;

$(document).ready(function() {    

  /* Add a click handler to the rows - this could be used as a callback */
  $('#grid tr').click( function() {
    if ( $(this).hasClass('row_selected') )
    {     
      $(this).removeClass('row_selected');
      $(this).find('.checkbox').removeAttr('checked');
    }     
    else
    {
      $(this).addClass('row_selected');
      $(this).find('.checkbox').attr('checked', 'checked');
    }     
  });
  
  /* Init DataTables */
  oTable = $('#grid').dataTable(
  { 
    "aaSorting": [],        
    "aoColumns": [
        { "bSortable": false },
        null,
        { "bSortable": false },
        { "bSortable": false }
    ],
                                  
    "bPaginate": true,
    "bLengthChange": true,
    "bFilter": true,  
    "bSort": true,
    "bInfo": true,
    "bAutoWidth": true,
    "bJQueryUI": true,
    "sPaginationType": "full_numbers" 
  }); 
}); 

/*
 * I don't actually use this here, but it is provided as it might be useful and demonstrates
 * getting the TR nodes from DataTables
 */
function fnGetSelected( oTableLocal )
{
  var aReturn = new Array();
  var aTrs = oTableLocal.fnGetNodes();
  
  for ( var i=0 ; i<aTrs.length ; i++ )
  {
    if ( $(aTrs[i]).hasClass('row_selected') )
    {
      aReturn.push( aTrs[i] );
    }
  }
  return aReturn;
}
</script>